home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_015 / okidatadump / render.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  2KB  |  77 lines

  1. /* Graphics render for Okidata ML 92 */
  2.  
  3. #include "exec/types.h"
  4. #include "exec/nodes.h"
  5. #include "exec/lists.h"
  6. #include "exec/memory.h"
  7. #include "devices/prtbase.h"
  8.  
  9. extern struct PrinterData *PD;
  10.  
  11. int Render(ct, x, y, status)
  12. UBYTE ct ;    /* color type = 0 for b&w printers */
  13. UWORD x, y ;    /* x and y coordinates of pixel */
  14.         /* or pc and pr print values, or special */
  15. UBYTE status ;    /* print status (0-init, 1-enter_pixel, 2-dump) */
  16. {
  17.     static UWORD BUFSIZE;
  18.     static char *SpoolBuffer ;
  19.     char *malloc() ;
  20.     UWORD i, k;            /* mics. var */
  21.     BYTE err;            /* the error # */
  22.  
  23.     switch(status) {
  24.  
  25.     case 0 : /* allocate memory for printer buffer */
  26.         BUFSIZE = x;
  27.         PD->pd_PrintBuf = (UBYTE *)AllocMem(BUFSIZE,MEMF_PUBLIC);
  28.         SpoolBuffer = (char *)AllocMem(BUFSIZE*2+5,MEMF_PUBLIC);
  29.                     /* used to actually print */
  30.         if (err=(PD->pd_PrintBuf == 0)) return(err);
  31.         (*(PD->pd_PWrite))("\30\33%C000\34",8);
  32.             /* non graphic, clear, clear left margin, 72 DPI */
  33.         return(0) ;
  34.         break ;
  35.  
  36.     case 1 : /* put pixel in buffer */
  37.         PD->pd_PrintBuf[x] = PD->pd_PrintBuf[x] | (1 << (y % 7));
  38.         return(0) ; /* flag all ok */
  39.         break ;
  40.  
  41.     case 2 : /* dump buffer to printer */
  42.         k = 1 ;
  43.         for (i=0 ; i < BUFSIZE; i++ ) {
  44.             SpoolBuffer[k] = PD->pd_PrintBuf[i]&127 ;
  45.             if (SpoolBuffer[k++] == '\3') /* double ETX */
  46.                 SpoolBuffer[k++] = '\3' ;
  47.         }
  48.         SpoolBuffer[0]   = '\03' ; /* Begin graphic mode */
  49.         SpoolBuffer[k++] = '\03' ; /* Graphic linefeed */
  50.         SpoolBuffer[k++] = '\16' ;
  51.         SpoolBuffer[k++] = '\03' ; /* End graphic mode */
  52.         SpoolBuffer[k++] = '\02' ;
  53.  
  54.         (*(PD->pd_PWrite))(SpoolBuffer,k); /* write out Buffer */
  55.  
  56.         return(0) ; /* flag all ok */
  57.         break ;
  58.  
  59.     case 3 : /* clear and init buffer */
  60.         for (i=0; i< BUFSIZE; i++)
  61.             PD->pd_PrintBuf[i] = 0 ;
  62.         return(0) ; /* flag all ok */
  63.         break ;
  64.  
  65.     case 4 : /* free print buffer memory */
  66.         (*(PD->pd_PBothReady))() ;
  67.         FreeMem(PD->pd_PrintBuf,BUFSIZE) ;
  68.         FreeMem(SpoolBuffer,BUFSIZE*2+5) ;
  69.         return(0) ;
  70.         break ;
  71.  
  72.     default:
  73.         return(0) ;
  74.     }
  75. }
  76.  
  77.